package com.epro.dx.util;

import com.weipu.common.util.ThreadUtil;

import android.os.AsyncTask;
import android.os.Build;

public class AsyncTaskUtil {
	private static int HONEYCOMB_NUM=0;

	public static void executeTask(AsyncTask<Void, Void, String> task) {
		if (HONEYCOMB_NUM==1) {
			task.executeOnExecutor(ThreadUtil.getInstance()
					.getThreadPoolIntance());
			return;
		}else if(HONEYCOMB_NUM==2){
			task.execute();
			return;
		}
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			HONEYCOMB_NUM=1;
			task.executeOnExecutor(ThreadUtil.getInstance()
					.getThreadPoolIntance());
		} else {
			HONEYCOMB_NUM=2;
			task.execute();
		}
	}
	
	public static void executeIntegerTask(AsyncTask<Integer, Void, String> task) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			task.executeOnExecutor(ThreadUtil.getInstance()
					.getThreadPoolIntance());
		} else {
			task.execute();
		}
	}
	
	public static void executeVoidTask(AsyncTask<Void, Void, Void> task) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			task.executeOnExecutor(ThreadUtil.getInstance()
					.getThreadPoolIntance());
		} else {
			task.execute();
		}
	}
	public static void executeBoleanTask(AsyncTask<Void, Void, Boolean> task) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			task.executeOnExecutor(ThreadUtil.getInstance()
					.getThreadPoolIntance());
		} else {
			task.execute();
		}
	}
}
